home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / 3deng.h < prev    next >
Text File  |  1996-01-19  |  5KB  |  309 lines

  1.                        
  2. /********************************************************/                                                         
  3. /*          3D ENGINE - Header File   17/01/95          */
  4. /********************************************************/
  5.  
  6. #ifndef _3DENG_H_
  7. #define _3DENG_H_
  8.  
  9.  
  10. /**************/
  11. /* DATA TYPES */
  12.  
  13. //Data size definitions
  14. //use these as often as possible
  15. typedef signed char byte;
  16. typedef signed short word;
  17. typedef signed int dword;
  18. #ifndef BYTE
  19. typedef unsigned char BYTE;
  20. #endif
  21. /*
  22. #ifndef WORD
  23. typedef unsigned short WORD;                                                                 
  24. #endif
  25. #ifndef DWORD
  26. typedef unsigned int DWORD;
  27. #endif
  28. */
  29. typedef float floatpt;
  30.  
  31. // Types used through 3D pipeline
  32. typedef floatpt datapt;
  33. typedef floatpt rotpt;
  34. typedef dword scrpt;
  35.  
  36. // Word / Byte union
  37. typedef union
  38.     {
  39.     struct {byte low,hiw;} d;
  40.     word c;
  41.     }
  42.     dchar_u;
  43.  
  44. // DoubleWord / Word union
  45. typedef union
  46.     {
  47.     struct {word low,hiw;} d;
  48.     dword dw;
  49.     }
  50.     dword_u;
  51.  
  52.  
  53.  
  54. /**************/
  55. /* MATH TYPES */
  56.  
  57. // General matrix type
  58. typedef floatpt mat[4][4];
  59.  
  60. // Rotation matrix type (explicit for speed).
  61. typedef union
  62.     {
  63.     mat arr;
  64.     struct
  65.         {
  66.         floatpt r00,r01,r02,r03;
  67.         floatpt r10,r11,r12,r13;
  68.         floatpt r20,r21,r22,r23;
  69.         }e;
  70.     }
  71.     qmat;
  72.  
  73.  
  74.  
  75. /*********************/
  76. /* 3D GEOMETRY TYPES */
  77.  
  78. // 3D point & point-list types
  79. typedef datapt *pt;
  80. typedef datapt ptlist[];
  81.  
  82.  
  83. // Face & face-list types
  84. typedef word *face;
  85. typedef word facelist[];
  86.  
  87.  
  88. // Rotated point type
  89. typedef rotpt *rpt;
  90.  
  91.  
  92.  
  93. /*********************/
  94. /* 2D GEOMETRY TYPES */
  95.  
  96. // Screen point type
  97. typedef struct
  98.     {
  99.     scrpt x,y;
  100.     }
  101.     pnt;
  102.  
  103. // Gourad screen point type
  104. typedef struct
  105.     {
  106.     scrpt x,y,col;
  107.     }
  108.     ppnt;
  109.  
  110. // Screen point with z type (Bi-Quadratic mapping)
  111. typedef struct
  112.     {
  113.     scrpt z,x,y;
  114.     }
  115.     zpnt;
  116.  
  117. // Screen polygon type (with average z for sort)
  118. typedef struct
  119.     {
  120.     rotpt z;
  121.     scrpt *pts;
  122.     }
  123.     pols;
  124.  
  125.  
  126.  
  127. /****************/
  128. /* OBJECT TYPES */
  129.  
  130. // Object type
  131. typedef struct
  132.     {
  133.     pt points;
  134.     face faces;
  135.     datapt x,y,z;
  136.     floatpt crot,srot;
  137.     }
  138.     obj;
  139.  
  140. // Object list type
  141. typedef struct
  142.     {
  143.     rotpt z;
  144.     pols *polys;
  145.     short nopols;
  146.     }
  147.     objs;
  148.  
  149. // Object detail level type
  150. typedef struct
  151.     {
  152.     rotpt zscale; // min z/q for this detail level
  153.     pt dpoints;
  154.     face dfaces;
  155.     }
  156.     det;
  157.  
  158. // Object detail level list
  159. typedef det detlist[];
  160.  
  161.  
  162.  
  163. /*****************/
  164. /* SURFACE TYPES */
  165.  
  166. // Texture type
  167. typedef dword texture[8]; // Assumes 4 pt textures, other nos of pts are padded out
  168.  
  169. // Polygon filter type
  170. typedef BYTE filter[256];
  171.  
  172.  
  173.  
  174. /************************/
  175. /* MOTION CAPTURE TYPES */
  176.  
  177. // Specific for players only
  178. #define PLYRPTS 28
  179.  
  180. typedef datapt capfrm[PLYRPTS*3+1];
  181.  
  182. typedef struct
  183.     {
  184.     word cappts,capfrms;
  185.     } mcap;
  186.  
  187.  
  188.  
  189. /*********************/
  190. /* PLAYER INFO TYPES */
  191.  
  192. typedef struct
  193.     {
  194.     floatpt x,y,z,crot,srot,frame,fstep;
  195.     short type,number,anim,sprite;
  196.     BYTE htype,hcol;
  197.     } plyrdat;
  198.  
  199. typedef struct
  200.     {
  201.     datapt *twnfrm;
  202.     capfrm twnpts1,twnpts2;
  203.     floatpt tween,tstep;
  204.     short anim,animto;
  205.     } plyrtwdat;
  206.  
  207.  
  208.  
  209. /**************/
  210. /* MISC TYPES */
  211.  
  212. typedef struct
  213.     {
  214.     short sky;
  215.     short stadia;
  216.     short pitch;
  217.     short players;
  218.     short lines;
  219.     short shadows;
  220.     }
  221.     detail_info;
  222.  
  223. // Setup data type
  224. typedef struct
  225.     {
  226.     short M8;
  227.     short team_a,team_b;
  228.     short team_b_kit;
  229.     short stadium;
  230.     short vidi_type;
  231.     short start_res;
  232.     short screen_size;
  233.     short verbose;
  234.     detail_info detail; 
  235.     }
  236.     setup_info;
  237.  
  238. // Screen buffer info type
  239. typedef struct
  240.     { 
  241.     BYTE *buff_start;
  242.     scrpt buff_wid,buff_hgt;
  243.     scrpt clip_wid,clip_hgt;
  244.     float scale_x,scale_y;
  245.     void (*dump)(scrpt dispx,scrpt dispy);
  246.     }
  247.     buff_info;
  248.  
  249. // Extended screen buffer info type
  250. typedef struct
  251.     { 
  252.     BYTE *buff_start;
  253.     BYTE *clip_end,*clip_endl;
  254.     scrpt buff_wid,buff_hgt;
  255.     scrpt clip_wid,clip_hgt,clip_widl,clip_hgtl;
  256.     scrpt clip_xmid,clip_ymid;
  257.     float scale_x,scale_y;
  258.     void (*dump)(scrpt dispx,scrpt dispy);
  259.     }
  260.     buff_info_ext;
  261.  
  262. typedef struct {
  263.     int pitchfile,pitchpfile;
  264.     char skytypes[2];
  265.     int tmdfile;
  266.     int sb1file,sb2file;
  267.     datapt s1x,s1y,s1z;
  268.     int s1pfile,s1ffile;
  269.     datapt s2x,s2y,s2z;
  270.     int s2pfile,s2ffile;
  271.     datapt s3x,s3y,s3z;
  272.     int s3pfile,s3ffile;
  273.     datapt s4x,s4y,s4z;
  274.     int s4pfile,s4ffile;
  275.     int st_w,st_l,st_h;
  276.     short noloop;
  277.     int loop[20];
  278.     int vid1x,vid1y,vid1z;
  279.     int vid2x,vid2y,vid2z;
  280.     int tunlx,tunly,tunlz;
  281.     int vmap;
  282.     } 
  283.     stad_info;
  284.  
  285. typedef struct {
  286.     int headfile;
  287.     int torsofile;
  288.     int limbsfile;
  289.     int nosfile;
  290.     int palfile;
  291.     int skinfile;
  292.     int homepfile;
  293.     int awaypfile;
  294.     }
  295.     teamk_info;
  296.  
  297.  
  298.  
  299. /***********************/
  300. /* FUNCTION PROTOTYPES */
  301.  
  302. int init3d();
  303. void setscreen();
  304. void end3d();
  305. void render3d(buff_info *buffer,datapt viewx,datapt viewy,datapt viewz,datapt targx,datapt targy,
  306.               datapt targz,datapt vdist,plyrdat *plyrtb,datapt *xyz_ptr,word *ref_ptr);
  307.  
  308. #endif
  309.